const express = require('express')
const router = express.Router()

const { getHotelCount, getHotelList, searchHotel, toggleHotHotel, deleteHotel, publishHotelData } = require('../../controller/apis/HotelController')
const { createUploadMiddleware } = require('../../middleware/UploadImageMiddleware')

// 导入JWT拦截中间件
const checkTokenMiddleware = require('../../middleware/checkTokenMiddleware')
// 导入分页中间件
const paginationMiddleware = require('../../middleware/paginationMiddleware');

// 获取酒店总数
router.get('/hotel/count', checkTokenMiddleware, getHotelCount)

// 获取酒店列表信息
router.get('/hotel/list', paginationMiddleware, checkTokenMiddleware, getHotelList)

// 酒店列表搜索功能
router.get('/hotel/search', checkTokenMiddleware, searchHotel)

// 酒店热门状态切换
router.patch('/hotel/hot/toggle/:id', checkTokenMiddleware, toggleHotHotel)

// 删除酒店
router.delete('/hotel/del/:id', checkTokenMiddleware, deleteHotel)

// 上传酒店图片
const uploadPostImages = createUploadMiddleware('Hotel')
router.post('/hotel/upload', checkTokenMiddleware, uploadPostImages)

// 发布酒店
router.post('/hotel/publish', checkTokenMiddleware, publishHotelData)

module.exports = router